﻿using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;

namespace RESTfulAPI
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class StudentQueryService : IStudentQuery
    {
        private List<Student> Students = new List<Student>();

        public StudentQueryService()
        {
            Students.Add(new Student() { Name = "张三", Age = 18 });
            Students.Add(new Student() { Name = "李四", Age = 17 });
        }

        public Student GetStudent(string name)
        {
            return Students.FirstOrDefault(o => o.Name == name);
        }

        public Student GetStudentByage(int age)
        {
            return Students.FirstOrDefault(o => o.Age == age);
        }
    }
}
